<template>
    <div class="v-dialog">
        <div class="head">
            <el-select v-model="status" :placeholder="$selectPlease('config.freezeReason')">
                <el-option
                        v-for="item in options"
                        :key="item.code"
                        :label="item.description"
                        :value="item.code">
                </el-option>
            </el-select>
        </div>
        <div>
            <v-table
                :page="page"
                    :hasEdit="false"
                    :pageSize="pageSize"
                    :tableConfig="dialogConfig"
                    :tableData="tableData"
                    :total="total"
                    :height="'270px'"
                    @findData="getTableData"
                    @getTableData="getTableData"
                    @searhData="searhData"
                    @selectData="selectData"
                    @upData="getTableData"
                    ref="table"
            ></v-table>
        </div>
        <div>
            <el-input v-model="comments" :placeholder="$t('app.remark')"></el-input>
        </div>
    </div>
</template>

<script>
    import table from "commons/Table";
    import baseMixin from "@/mixins/BaseMixin";

    export default {
        name: "",
        mixins: [baseMixin],
        props: {
            dialogConfig: {
                type: Array
            },
            dialogUrl: {
                type: String
            }
        },
        data() {
            return {
                tableConfig: [],
                tableData: [],
              page: 1,
                pageSize: 10,
                total: 10,
                url: "",
                tableSelectData: [],
                tableSearhData: {},
                options: this.getOptions("queryInventoryholdcodeDropDown"),
                status: "",
                comments: ""
            }
        },
        comments: {},
        methods: {
            selectData(data) {
                this.tableSelectData = data;
            },
            async getTableData(page, data) {
                try {
                    this.loading = true;
                    let res = await this.$api.post(`${this.dialogUrl}/${page}`, data);
                    
                        this.tableData = res.page.list;
                      this.page = res.page.curpage;
                        this.pageSize = res.page.pageSize;
                        this.total = res.page.total;
                    
                } catch (e) {
                    this.$message.error(e);
                } finally {
                    this.loading = false;
                }
            },
            searhData(data, up) {
                if (!up) {
                    this.tableSearhData = data;
                } else {
                    this.tableSearhData = data;
                    this.getTableData(1, this.tableSearhData);
                }
            },
        },
        mounted() {
            this.getTableData(1, {});
            // this.options = this.getOptions("queryInventoryholdcodeDropDown");
        },
        components: {
            "v-table": table
        },
    }
</script>

<style scoped>
    .v-dialog {
        padding: 5px 10px;
    }

    .el-select {
        width: 100%;
    }
</style>
